package 泛型;

class Pe {
    public String toString() {
        return "Person";
    }

}

class Fruit {
    public String toString() {
        return "Fruit";
    }

}

class Apple extends Fruit {
    public String toString() {
        return "Apple";
    }

}


public class Te<T> { //主类，把你文件名改成ClassName.java

    void show_1(T t) {
        System.out.println("show_1  " + t.toString());
    }

    <T> void show_2(T t) {
        System.out.println("show_2  " + t.toString());
    }

    <T> void show_3(T t) {
        System.out.println("show_3  " + t.toString());
    }


    public static void main(String[] args) {
        Te<Fruit> o = new Te<Fruit>();
        Fruit f = new Fruit();
        Apple a = new Apple();
        Pe p = new Pe();
        System.out.println("show_1 演示________________________");
        o.show_1(f);
        o.show_1(a);
        //    o.show_1( p );  //楼主把这行代码去掉注释看一下，是不能编译通过的。因为在
//	        ClassName<Fruit>中已经限定了全局的T为Fruit，所以不能再加入Person;
        System.out.println("show_2 演示________________________");
        o.show_2(f);
        o.show_2(a);
        o.show_2(p);
        System.out.println("show_3 演示________________________");
        o.show_3(f);
        o.show_3(a);
        o.show_3(p);


    }
}
